public class Solution {
    public boolean CheckPermutation(String s1, String s2) {
        if(s1.length() != s2.length())  return false;

        int[] hash = new int[26];
        for(int i = 0; i < s1.length(); i++) {
            hash[s1.charAt(i) - 'a']++;
        }
        for(int i = 0; i < s2.length(); i++) {
            hash[s2.charAt(i) - 'a']--;
            if(hash[s2.charAt(i) - 'a'] < 0)    return false;
        }
        return true;
        }


    public static void main(String[] args) {
        String s1 = "abc";
        String s2 = "bad";
        Solution solution = new Solution();
        System.out.println(solution.CheckPermutation(s1,s2));
    }
}
